FROM codercom/code-server:3.10.2

USER root

# Apply VS Code settings
COPY deploy-container/settings.json .local/share/code-server/User/settings.json

# Use bash shell
ENV SHELL=/bin/bash

# Install unzip + rclone (support for remote filesystem)
RUN sudo apt-get update && sudo apt-get install unzip -y
RUN curl https://rclone.org/install.sh | sudo bash

# Copy rclone tasks to /tmp, to potentially be used
COPY deploy-container/rclone-tasks.json /tmp/rclone-tasks.json

# Fix permissions for code-server
RUN sudo chown -R coder:coder /home/coder/.local

# You can add custom software and dependencies for your environment below
# -----------

# Install a VS Code extension:
# Note: we use a different marketplace than VS Code. See https://github.com/cdr/code-server/blob/main/docs/FAQ.md#differences-compared-to-vs-code
# RUN code-server --install-extension esbenp.prettier-vscode

# Install apt packages:
# RUN sudo apt-get install -y ubuntu-make

# Copy files: 
# COPY deploy-container/myTool /home/coder/myTool

# -----------
RUN sudo apt-get update && sudo apt-get install -y default-jdk
# 安装maven
RUN sudo apt-get install -y maven

# 安装gradle
RUN sudo apt-get install -y wget && wget https://services.gradle.org/distributions/gradle-5.0-bin.zip -P /tmp \
&& sudo unzip -d /opt/gradle /tmp/gradle-*.zip 
RUN sudo bash -c "echo -e 'export GRADLE_HOME=/opt/gradle/gradle-5.0 \nexport PATH=\${GRADLE_HOME}/bin:\${PATH}' > /etc/profile.d/gradle.sh"\
&& sudo chmod +x /etc/profile.d/gradle.sh && echo 'source /etc/profile.d/gradle.sh ' >> /home/coder/.bashrc


RUN code-server --install-extension vsls-contrib.codetour
RUN sudo code-server --install-extension vsls-contrib.codetour \
vscjava.vscode-java-pack vscjava.vscode-java-dependency vscjava.vscode-java-test vscjava.vscode-maven \
redhat.java vscjava.vscode-java-debug\
isudox.vscode-jetbrains-keybindings k--kato.intellij-idea-keybindings\
&& sudo cp /home/coder/.bashrc /root/.bashrc
EXPOSE 8081

# Port
ENV PORT=8080

# Use our custom entrypoint script first
COPY deploy-container/entrypoint.sh /usr/bin/deploy-container-entrypoint.sh
ENTRYPOINT ["/usr/bin/deploy-container-entrypoint.sh"]
